home *** CD-ROM | disk | FTP | other *** search
- rem
- rem @(#)u.patchone.bat 1.6 03/14/97
- rem (c) Insignia Solutions plc, 1997.
- rem
- rem PATCHONE - Batch file to save copies of files to be patched
- rem and to apply the patch. Takes parameters:
- rem
- rem 1: File to be patched. eg. "vtd.386"
- rem
- rem 2: Directory containing file. eg. "c:\windows\system"
- rem
- rem 3..7: Parameters to pass to patch program. eg. "-VTD" or "WIN311"
- rem
- rem It uses INSPAT95 to do the patching if it exists and INSPATCH
- rem if it doesn't. Therefore to patch a commpressed VxD library,
- rem such as VMM32.VXD, INSPAT95 should be created before calling
- rem this batch file.
-
- echo Patching %2\%1 >>c:\insignia\up.log
-
- rem IMPORTANT: We have a problem with command line lengths - DOS imposes a
- rem 128-character limit. To alleviate this we:
- rem (1) change directory to %2 and make copies of the file.
- rem (2) change directory to c:\insignia and leave that off the first three
- rem elements of the inspatch command line and off the log file.
-
- set patchone_drive=XX
- ibatch patchone_drive string %2 0 2
- %patchone_drive%
- if not "%2" == "%patchone_drive%" cd %2
-
- rem Ensure directory exists for original copies of files.
- rem Gotcha - cannot use "if exist somepath\nul" on FSA drive!
- set patchone_odir=xxxxxxxxxxxxxxxx
- dir /b/ad | find "ORIGINAL.SAV" | ibatch patchone_odir string 0 0
- if not "%patchone_odir%" == "ORIGINAL.SAV" mkdir original.sav >>c:\insignia\up.log
-
- rem Save a copy of the very first version of the file we ever see.
- rem If there is an original copy in c:\insignia\old (historical location),
- rem move that into the new location in preference.
- if exist c:\insignia\old\%1 MOVE /Y c:\insignia\old\%1 original.sav\%1 >>c:\insignia\up.log
- if not exist original.sav\%1 COPY /Y %1 original.sav\%1 >>c:\insignia\up.log
-
- rem Save a copy of the current version of the file.
- COPY /Y %1 c:\insignia\PATCH.WRK >>c:\insignia\up.log
-
- rem Cater for the file being read only.
- if "%patchone_drive%" == "C:" goto cdrive
- if "%patchone_drive%" == "c:" goto cdrive
-
- rem If the file is on FSA and user is not its owner,
- rem we cannot simply execute "attrib -r". We can
- rem however move the file to another location on the
- rem same drive, where it will remain.
- rem The initial set commands just reserves environment space.
- set patchone_ro=X
- ATTRIB %1 | ibatch patchone_ro string 7 1
- if "%patchone_ro%" == "R" move /y %1 original.sav\ro_files\%1 >>c:\insignia\up.log
- goto alldrives
-
- :cdrive
- ATTRIB -R %1 >>c:\insignia\up.log
- :alldrives
-
- c:
- cd \insignia
-
- rem Work out which patcher to use.
- rem Leaving off the ".exe" extension saves another 4 command line characters.
- SET INSPATCH=INSPAT95
- if not exist INSPAT95.EXE SET INSPATCH=INSPATCH
-
- rem Patch the saved current version of the file.
- %INSPATCH% PATCH.PAT PATCH.WRK %2\%1 %3 %4 %5 %6 %7 >>up.log
-
- rem Check whether we succeeded.
- if exist %2\%1 goto endit
-
- rem Record that patching current version failed.
- echo Trying %2\original.sav\%1 instead >>up.log
-
- rem Patch the saved original version of the file.
- rem Another measure to save command line length: copy the original file
- rem (which has quite a long path) to patch.wrk in the cd and patch that.
- copy /y %2\original.sav\%1 patch.wrk >>up.log
- %INSPATCH% PATCH.PAT patch.wrk %2\%1 %3 %4 %5 %6 %7 >>up.log
-
- rem Check whether we succeeded this time.
- if exist %2\%1 goto endit
-
- rem Restore the current version of the file.
- COPY /Y PATCH.WRK %2\%1 >>up.log
-
- rem Record that patching failed.
- echo Patching %2\%1 failed! >>up.log
- rem ***** Set failure flag here *****
-
- :endit
- rem Delete the working copy of the file.
- DEL PATCH.WRK >>up.log